package org.example.utils;

/**
 * 类型
 **/
public enum TypeEnumUtil {

    VARCHAR("varchar", "String"),
    DATETIME("datetime", "Timestamp"),
    TIMESTAMP("timestamp", "Timestamp"),
    INT("int", "Integer"),
    TINYINT("tinyint", "Byte"),
    DECIMAL("decimal", "BigDecimal"),
    TEXT("text", "String"),
    SAMLLINT("smallint", "Integer"),
    DOUBLE("double", "Double"),
    TIME("time", "Time"),
    DATE("date", "Date"),
    BIGINT("bigint", "Long"),
    ;
    /**
     * 数据库类型
     */
    private String sqlType;
    /**
     * java类型
     */
    private String javaType;

    TypeEnumUtil(String sqlType, String javaType) {
        this.javaType = javaType;
        this.sqlType = sqlType;
    }

    public static TypeEnumUtil valueOfJavaType(String sqlType) {
        TypeEnumUtil[] sqlTypes = TypeEnumUtil.values();
        for (TypeEnumUtil s : sqlTypes) {
            if (s.sqlType.equalsIgnoreCase(sqlType)) {
                return s;
            }
        }
        throw new RuntimeException(String.format("没有定义[%s]类型", sqlType));
    }

    public String getSqlType() {
        return sqlType;
    }

    public void setSqlType(String sqlType) {
        this.sqlType = sqlType;
    }

    public String getJavaType() {
        return javaType;
    }

    public void setJavaType(String javaType) {
        this.javaType = javaType;
    }


}
